home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / axcool / comdlg.cls < prev    next >
Text File  |  1998-10-26  |  36KB  |  1,189 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4. END
  5. Attribute VB_Name = "clsCommonDialog"
  6. Attribute VB_GlobalNameSpace = False
  7. Attribute VB_Creatable = True
  8. Attribute VB_PredeclaredId = False
  9. Attribute VB_Exposed = False
  10. Attribute VB_Ext_KEY = "SavedWithClassBuilder" ,"Yes"
  11. Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
  12. Option Explicit
  13.  
  14. Private m_cancelled As Boolean
  15. 'API function called by ChooseColor method
  16. Private Declare Function ChooseColor Lib "comdlg32.dll" Alias "ChooseColorA" (pChoosecolor As ChooseColor) As Long
  17.  
  18. 'API function called by ChooseFont method
  19. Private Declare Function CHOOSEFONT Lib "comdlg32.dll" Alias "ChooseFontA" (pChoosefont As ChooseFontType) As Long
  20.  
  21. 'API function inside ShowHelp method
  22. Private Declare Function WinHelp Lib "user32" Alias "WinHelpA" (ByVal hwnd As Long, ByVal lpHelpFile As String, ByVal wCommand As Long, ByVal dwData As Long) As Long
  23.  
  24. 'API function called by ShowOpen method
  25. Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (pOpenfilename As OpenFilename) As Long
  26.  
  27. 'API function called by ShowSave method
  28. Private Declare Function GetSaveFileName Lib "comdlg32.dll" Alias "GetSaveFileNameA" (pOpenfilename As OpenFilename) As Long
  29.  
  30. 'API function called by ShowPrint method
  31. Private Declare Function PrintDlg Lib "comdlg32.dll" Alias "PrintDlgA" (pPrintdlg As PrintDlg) As Long
  32.  
  33.  
  34. 'API function to retrieve extended error information
  35. Private Declare Function CommDlgExtendedError Lib "comdlg32.dll" () As Long
  36.  
  37. 'API memory functions
  38. Private Declare Function GlobalAlloc Lib "KERNEL32" (ByVal wFlags As Long, ByVal dwBytes As Long) As Long
  39. Private Declare Function GlobalFree Lib "KERNEL32" (ByVal hMem As Long) As Long
  40. Private Declare Function GlobalLock Lib "KERNEL32" (ByVal hMem As Long) As Long
  41. Private Declare Function GlobalUnlock Lib "KERNEL32" (ByVal hMem As Long) As Long
  42.  
  43. Private Declare Sub CopyMemory Lib "KERNEL32" Alias "RtlMoveMemory" ( _
  44.          hpvDest As Any, hpvSource As Any, ByVal cbCopy As Long)
  45.  
  46. Private Const cdlCFANSIOnly = &H400    'Specifies that the dialog box allows only a selection of the fonts that use the Windows character set. If this flag is set, the user won't be able to select a font that contains only symbols.
  47. Private Const cdlCFApply = &H200   'Enables the Apply button on the dialog box.
  48. Private Const cdlCFBoth = &H3      'Causes the dialog box to list the available printer and screen fonts. The hDC property identifies the device context associated with the printer.
  49. Private Const cdlCFEffects = &H100     'Specifies that the dialog box enables strikethrough, underline, and color effects.
  50. Private Const cdlCFFixedPitchOnly = &H4000 'Specifies that the dialog box selects only fixed-pitch fonts.
  51. Private Const cdlCFForceFontExist = &H10000    'Specifies that an error message box is displayed if the user attempts to select a font or style that doesn't exist.
  52. Private Const cdlCFHelpButton = &H4    'Causes the dialog box to display a Help button.
  53. Private Const cdlCFLimitSize = &H2000  'Specifies that the dialog box selects only font sizes within the range specified by the Min and Max properties.
  54. Private Const cdlCFNoFaceSel = &H80000     'No font name selected.
  55. Private Const cdlCFNoSimulations = &H1000  'Specifies that the dialog box doesn't allow graphic device interface (GDI) font simulations.
  56. Private Const cdlCFNoSizeSel = &H200000    'No font size selected.
  57. Private Const cdlCFNoStyleSel = &H100000
  58. Private Const cdlCFNoVectorFonts = &H800   'Specifies that the dialog box doesn't allow vector-font selections.
  59. Private Const cdlCFPrinterFonts = &H2      'Causes the dialog box to list only the fonts supported by the printer, specified by the hDC property.
  60. Private Const cdlCFScalableOnly = &H20000      'Specifies that the dialog box allows only the selection of fonts that can be scaled.
  61. Private Const cdlCFScreenFonts = &H1       'Causes the dialog box to list only the screen fonts supported by the system.
  62. Private Const cdlCFTTOnly = &H40000    'Specifies that the dialog box allows only the selection of TrueType fonts.
  63. Private Const cdlCFWYSIWYG = &H8000    'Specifies that the dialog box allows only the selection of fonts that are available on both the printer and on screen. If this flag is set, the cdlCFBoth and cdlCFScalableOnly flags should also be set
  64.  
  65.  
  66.  
  67. 'constants for API memory functions
  68. Private Const GMEM_MOVEABLE = &H2
  69. Private Const GMEM_ZEROINIT = &H40
  70. Private Const GHND = (GMEM_MOVEABLE Or GMEM_ZEROINIT)
  71.  
  72.  
  73. 'data buffer for the ChooseColor function
  74. Private Type ChooseColor
  75.         lStructSize As Long
  76.         hwndOwner As Long
  77.         hInstance As Long
  78.         rgbResult As Long
  79.         lpCustColors As Long
  80.         flags As Long
  81.         lCustData As Long
  82.         lpfnHook As Long
  83.         lpTemplateName As String
  84. End Type
  85.  
  86. 'constants for LOGFONT
  87. Private Const LF_FACESIZE = 32
  88. Private Const LF_FULLFACESIZE = 64
  89. Private Const FW_BOLD = 700
  90.  
  91. 'data buffer for the ChooseFont function
  92. Private Type LOGFONT
  93.         lfHeight As Long
  94.         lfWidth As Long
  95.         lfEscapement As Long
  96.         lfOrientation As Long
  97.         lfWeight As Long
  98.         lfItalic As Byte
  99.         lfUnderline As Byte
  100.         lfStrikeOut As Byte
  101.         lfCharSet As Byte
  102.         lfOutPrecision As Byte
  103.         lfClipPrecision As Byte
  104.         lfQuality As Byte
  105.         lfPitchAndFamily As Byte
  106.         lfFaceName(LF_FACESIZE) As Byte
  107. End Type
  108.  
  109. 'data buffer for the ChooseFont function
  110. Private Type ChooseFontType
  111.         lStructSize As Long
  112.         hwndOwner As Long
  113.         hdc As Long
  114.         lpLogFont As Long
  115.         iPointSize As Long
  116.         flags As Long
  117.         rgbColors As Long
  118.         lCustData As Long
  119.         lpfnHook As Long
  120.         lpTemplateName As String
  121.         hInstance As Long
  122.         lpszStyle As String
  123.         nFontType As Integer
  124.         MISSING_ALIGNMENT As Integer
  125.         nSizeMin As Long
  126.         nSizeMax As Long
  127. End Type
  128.  
  129.  
  130. 'data buffer for the GetOpenFileName and GetSaveFileName functions
  131. Private Type OpenFilename
  132.         lStructSize As Long
  133.         hwndOwner As Long
  134.         hInstance As Long
  135.         lpstrFilter As String
  136.         lpstrCustomFilter As String
  137.         nMaxCustFilter As Long
  138.         iFilterIndex As Long
  139.         lpstrFile As String
  140.         nMaxFile As Long
  141.         lpstrFileTitle As String
  142.         nMaxFileTitle As Long
  143.         lpstrInitialDir As String
  144.         lpstrTitle As String
  145.         flags As Long
  146.         nFileOffset As Integer
  147.         nFileExtension As Integer
  148.         lpstrDefExt As String
  149.         lCustData As Long
  150.         lpfnHook As Long
  151.         lpTemplateName As String
  152. End Type
  153.  
  154.  
  155. 'data buffer for the PrintDlg function
  156. Private Type PrintDlg
  157.         lStructSize As Long
  158.         hwndOwner As Long
  159.         hDevMode As Long
  160.         hDevNames As Long
  161.         hdc As Long
  162.         flags As Long
  163.         nFromPage As Integer
  164.         nToPage As Integer
  165.         nMinPage As Integer
  166.         nMaxPage As Integer
  167.         nCopies As Integer
  168.         hInstance As Long
  169.         lCustData As Long
  170.         lpfnPrintHook As Long
  171.         lpfnSetupHook As Long
  172.         lpPrintTemplateName As String
  173.         lpSetupTemplateName As String
  174.         hPrintTemplate As Long
  175.         hSetupTemplate As Long
  176. End Type
  177.  
  178.  
  179. 'internal property buffers
  180.  
  181. Private iAction As Integer         'internal buffer for Action property
  182. Private bCancelError As Boolean    'internal buffer for CancelError property
  183. Private lColor As Long             'internal buffer for Color property
  184. Private lCopies As Long            'internal buffer for lCopies property
  185. Private sDefaultExt As String      'internal buffer for sDefaultExt property
  186. Private sDialogTitle As String     'internal buffer for DialogTitle property
  187. Private sFileName As String        'internal buffer for FileName property
  188. Private sFileTitle As String       'internal buffer for FileTitle property
  189. Private sFilter As String          'internal buffer for Filter property
  190. Private iFilterIndex As Integer    'internal buffer for FilterIndex property
  191. Private lFlags As Long             '